<template>
	<div>
		<test v-model="form1" ref="form1"></test>

		<br>
		<el-button @click="detail()">获取数据</el-button>
		<el-button @click="submit()" type="primary">提交</el-button>
	</div>
</template>

<script>
import test from '@/components/test/test';
export default {
	components:{
		test
	},
	data () {
		return {
			form:{
				contentId:'',
				price:'',
				areaId:'',
				areaName:'',
				cityId:'',
				cityName:''
			},
			form1:{
				name:'',
				scale:''
			}
		}
	},
	methods:{
		// 查询
		detail(){
			// 请求
			let res = {
				contentId:'SHS10086',
				price:'800',
				areaId:'',
				areaName:'',
				cityId:'',
				cityName:'',
				name:'test',
				scale:0.6
			};
			
			// 涨幅比例*100
			res.scale = res.scale*100;
			
			// 传值给子组件
			for(let key in res){
				this.form1[key] = res[key]?res[key]:''
			};
		},
		// 提交
		submit(){
			// 执行子组件方法
			this.$refs.form1.submit();
			if(this.$refs.form1.valid){
				/*
					涨幅比例*100
				*/
				let form1 = Object.assign({},this.form1);
				form1.scale = form1.scale/100;
				/*
					提交
				*/
				let form = Object.assign(this.form,form1);
				console.log(form);
			}
		}
	},
	mounted(){

	}
}
</script>

<style lang="scss" scoped>
	.el-form-item{
		margin-bottom: 200px;
	}
</style>